﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOFrameworks;
using FooFun.DataElements.Dtos;

namespace FooFun.Web.Controls
{
    public class RelpyContentControl : DataElementControl
    {
        public override IDataElement DataElement
        {
            get
            {
                return base.DataElement;
            }
            set
            {
                if (value != null && !value.IsEmpty)
                {
                    IDataElement replyDE
                        = new RelpyContentDataElement(value);

                    base.DataElement = replyDE;

                    return;
                }
                base.DataElement = value;
            }
        }
    }

    public class RelpyContentDataElement : CustomDataElement
    {
        public RelpyContentDataElement(IDataElement de)
            : base(de)
        {

        }

        public override IDataElement this[string attrName]
        {
            get
            {
                if ("Conclusion" == attrName)
                {
                    /*
                    IDataElement conculsion = base.Parent.Parent
                        ["Conclusion/Content[@Ref="
                        + base["@EventId"] + "]"];
                    */

                    IDataElement conculsion = base.Parent.Parent
                       ["Conclusion/Content"];
                    return conculsion;

                }
                return base[attrName];
            }
            set
            {
                base[attrName] = value;
            }
        }
    }
}
